export const getHref = () => {
	return process.env.NODE_ENV === "development"
		? "https://supplier.alibaba.com/?joinSource=gw_baidu_LP_005057&bd_vid=15509706702966249308"
		: window.location.href;
};

export const getPageSourceInfo = () => {
	const originDict: Record<string, string> = {
		gw_baidu_LP_: "85001",
		gw_360_LP_: "85007",
		sem_ttiao_LP_: "85002",
		display_ttiao_LP_: "83001",
	};

	const joinSource =
		getHref().split("?").length >= 2
			? getHref()
					.split("?")[1]
					.split("&")
					.filter((item) => item.includes("joinSource"))[0] // maybe joinsource is null
					?.split("=")[1] || ""
			: "";

	const sourceItem = Object.keys(originDict).find((item) => joinSource?.includes(item));

	const origin = sourceItem ? originDict[sourceItem] : "58";
	return {
		origin,
		joinSource,
	};
};
